<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue directive</title>
    <script src="../assets/vue.js"></script>
</head>
<body>
<h1>vue.directive实例</h1>
<hr>
<div id="app">
    <div v-color="color">{{num}}</div>
    <p><button @click="add">add</button></p>
    <p><button @click="unbind">解绑</button></p>
</div>
<script>
    Vue.directive('color',function(el,binding){
        el.style = 'color:' + binding.value;
    })
    var app = new Vue({
        el:'#app',
        data:{
            num:1,
            color:'red'
        },
        methods:{
            add(){

            },
            unbind(){

            }
        }
    })
</script>
</body>
</html>